package com.itheima.service;
import com.itheima.entity.ReportClassDate;
import com.itheima.entity.ReportJobData;
import com.itheima.mapper.ReportMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService{
    @Autowired
    private ReportMapper reportMapper;

    @Override
    public ReportJobData empjobData() {
        List<Map<String, Object>> maps = reportMapper.jobData();

        List<Object> post = maps.stream().map(item -> item.get("post")).toList();
        List<Object> total = maps.stream().map(item -> item.get("total")).toList();

        return new ReportJobData(post,total);
    }

    @Override
    public List empGenderData() {
        return reportMapper.genderData();
    }

    @Override
    public List<Map> studentDegreeData() {
        return reportMapper.degreeData();
    }

    @Override
    public ReportClassDate studentCountData() {
        List<Map> maps = reportMapper.studentCountData();
        List<Object> clazzName = maps.stream().map(item -> item.get("clazzName")).toList();
        List<Object> total = maps.stream().map(item -> item.get("total")).toList();
        return new ReportClassDate(clazzName,total);
    }
}
